import request from '@/utils/request'

export const getEmployeeSimple = () => request({
  url: '/sys/user/simple'
})

// 获取所有员工
export const getEmployee = params => request({
  url: '/sys/user',
  params
})

// 删除员工
export const delEmployee = id => request({
  url: `/sys/user/${id}`,
  method: 'delete'
})

// 增加新员工
export const addEmployee = data => request({
  url: `/sys/user/`,
  method: 'POST',
  data
})

// 批量员工导入
export const imporEmployee = data => request({
  url: '/sys/user/batch',
  method: 'POST',
  data
})

// 保存员工基本信息
export const saveEmployeeInfo = data => request({
  url: `/sys/user/${data.id}`,
  method: 'PUT',
  data
})

/** *
 *  读取用户详情的基础信息
 * **/
export function getPersonalDetail(id) {
  return request({
    url: `/employees/${id}/personalInfo`
  })
}

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal(data) {
  return request({
    url: `/employees/${data.userId}/personalInfo`,
    method: 'put',
    data
  })
}

/** **
 * 获取用户的岗位信息
 *
 * ****/
export function getJobDetail(id) {
  return request({
    url: `/employees/${id}/jobs`
  })
}

/**
 * 保存岗位信息
 * ****/
export function updateJob(data) {
  return request({
    url: `/employees/${data.userId}/jobs`,
    method: 'put',
    data
  })
}
